/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.server.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.aeky.domain.Menu;
import com.aeky.server.dao.IMenuDao;

/**
 * 
 * @author aeky
 */
@Repository("menuDao")
public class MenuDaoImpl extends BaseDaoSupport<Menu> implements IMenuDao {

    /*
     * 
     * @see com.aeky.server.dao.IMenuDao#findAllMenu()
     */
    @Override
    public List<Menu> findAllMenu() {
        Query query = this.getEntityManager().createQuery("from Menu m where m.isValid = 1 and m.menuParentId = 0");
        List<Menu> list = (List<Menu>) query.getResultList();
        return list;
    }

    /*
     * 
     * @see
     * com.aeky.server.dao.IMenuDao#findAllValidMenuByLoginName(java.lang.String
     * )
     */
    @Override
    public List<Menu> findAllValidMenuByLoginName(String loginName) {
        Query query = this.getEntityManager().createQuery("from Menu m where m.isValid = 1 ");
        return query.getResultList();
    }

}
